<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<script>
			//访问对象的属性
			var msg = "Hello World!";
			var x= msg.length;
			console.log(x);
			//访问对象的方法
			var msg1 = "Hello Word!";
			var x1 = msg1.toUpperCase();
			console.log(x1);
			
			//创建 JavaScript 对象
			//使用Object
			var person = new Object();
			person.firstname = "John";
			person.lastname = "Doe";
			person.age = 50;
			person.eyecolor = "blue";
			//或者
			var person1 = {
				firstname:"John",
				lastname:"Doe",
				age:50,
				eyecolor:"blue",
				greet:function(){
					console.log('Hello,I am '+this.firstname + " " + this.lastname);
				}
			}
			person1.greet()
			//使用对象构造器
			function person2(firstname,lastname,age,eyecolor){
				this.firstname = firstname;
				this.lastname = lastname;
				this.age = age;
				this.eyecolor = eyecolor;
			}
			var person3 = new person2("John","Doe",50,"blue");
			console.log(person3)
			
			//JavaScript for...in 语句循环遍历对象的属性。
			for(var x in person3){
				console.log(person3[x]);
			}
			
			//JavaScript 的对象是可变的
			var person4 = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}
			var x = person4;
			x.age = 10;
			console.log(x.age,person4.age);
		</script>
		
	</body>
</html>